<%@ taglib prefix="s" uri="/struts-tags"%> 
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 <link href="../../../js/thickbox.css" rel="stylesheet" type="text/css" />
      <script src="../../../js/jquery-1.5.min.js" type="text/javascript"></script>
      <script src="../../../js/jqtool.js" type="text/javascript"></script>
      <script src="../../../js/ui.js" type="text/javascript"></script>
      <script src="../../../js/thickbox-compressed.js" type="text/javascript"></script>
		<script src="../../../js/jqui/jquery-1.2.6.min.js" type="text/javascript"></script>
 	   <link href="../../../css/Public.css"type="text/css" rel="stylesheet" />
       <link href="../../../css/PublicEdit.css"type="text/css" rel="stylesheet" /> 
       	<script language="javascript" src="../../../js/dateselect.js"></script> 
<title>修改广告 </title>
<style>
.gonggao{
    position:absolute;
    top:80px;
    left:200px;
    width:430px;
    height:300px;
    border:1px solid #993300;
    background-color:#ffffff;
}
.gonggao h1{
    line-height:50px;
    font-size:24px;
    font-family:"黑体";
    font-weight:bold;
    text-align:center;
}
.gonggao div{
    line-height:30px;
    font-size:18px;
    font-family:"黑体";
    text-align:center;
    color:#993300;
}
.gonggao div a,.gonggao div a:visited{
    color:#993300;
}
</style>

<script type="text/javascript">
    function clsGG(srcpath){
    	window.document.getElementById("viewimg").src= '${ctx}/showImage?imgfile='+srcpath;
    	//window.document.getElementById("viewimg").src=src;//"E://Workspaces//MyEclipse9//ksappstore//WebRoot//upload//800X600//460.jpg";
        jQuery("#gonggao").toggle();        
    }
    function closediv()
    {
    	document.all("gonggao").style.display="none";
    }
  
  function test(obj){
		  var str = document.getElementsByName("province");
	       if(obj.checked==true){
	       for(var i=0;i<str.length;i++){
	       document.getElementsByName("province")[i].checked = true;
	       }
	       }	       
	        if(obj.checked==false){
	       for(var i=0;i<str.length;i++){
	       document.getElementsByName("province")[i].checked = false;
	       }
	       }		
		}
</script>
<script type="text/javascript">		
			function checkData()
			{			
				    //验证数据   新广告名称
				    var uid=window.document.getElementById("adinfo_adid").value;
					var uname= window.document.getElementById("adinfo_title").value;	
					var str="false";
			        if(uname!=null && uname!="")
			        {			
			      	  //限制 字符和数字、长度
			        	if(uname.length>15)
			        	{
			        	 	alert("广告名称过长，最长15位！");
			        	 	window.document.getElementById("adinfo_title").focus();
			           		window.event.returnValue = false;
			            	return;
			        	}			
			        /*	<c:forEach var="blist" items="${list_AdInfo}">	
			 			 if(uname=="${blist.title}"&&uid!="${blist.adid}")
			 			 {
			     			 alert("该广告名称已经存在");
			     			 window.event.returnValue = false;
				  			 return;
					  	}		
        			  	</c:forEach>	*/       		
			        }
			        else
			        {            
			            alert("请输入广告名称！");
			            window.document.getElementById("adinfo_title").focus();
			            window.event.returnValue = false;
			            return;
			        }		
			        			
		 			var adinfo_url= window.document.getElementById("adinfo_url").value;	
			        if(adinfo_url!=null && adinfo_url!="")
			        {		
			        	//限制 字符和数字、长度
			        	if(adinfo_url.length>300)
			        	{
			        	 	alert("URL过长，最长300位！");
			        	 	window.document.getElementById("adinfo_url").focus();
			           		window.event.returnValue = false;
			            	return;
			        	}	
						   var strRegex = "^((https|http|ftp|rtsp|mms)://)?[a-z0-9A-Z]{3}\.[a-z0-9A-Z][a-z0-9A-Z]{0,61}?[a-z0-9A-Z]\.com|net|mobi|cn|cc|so (:s[0-9]{1-4})?/$";			  var re = new RegExp(strRegex);			  
						   var re =/^(https|http|ftp|rtsp|mms):\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/;
						   if(!re.test(adinfo_url)){
							     alert("URL不合法，请检查后重新输入");
							       document.getElementById("adinfo_url").focus();
							     window.event.returnValue = false;
			           			 return;							     
							 }  
							 $.ajaxSettings.async = false;
							 $.getJSON("/admin/json/isexsistAdUrl?uid="+uid+"&url=" + adinfo_url+"&rnd="+Math.random(), function(data) {
						  	 if(data.str=='Y'){
						  	 	alert("该广告已经存在！");						  	 	
				  			 	str="true";				  			 	
						 	}						
							}); 
							if(str=='true'){
							window.event.returnValue = false;
							return ;
							}
							
			        }
			        else
			        {            
			            alert("请输入URL！");
			            window.event.returnValue = false;
			            return;
			        }
			        
			        var adinfo_startdate= window.document.getElementById("adinfo_startdate").value;	
			        if(adinfo_startdate==null ||adinfo_startdate=="")
			        {	
			            alert("请选择开始日期！");
			            window.document.getElementById("adinfo_startdate").focus();
			            window.event.returnValue = false;
			            return;
			        }	
			        var adinfo_enddate= window.document.getElementById("adinfo_enddate").value;	
			        if(adinfo_enddate==null ||adinfo_enddate=="")
			        {	
			            alert("请选择结束日期！");
			            window.document.getElementById("adinfo_enddate").focus();
			            window.event.returnValue = false;
			            return;
			        }	
			        
			         if(Date.parse(adinfo_startdate.replace("-","/")) > Date.parse(adinfo_enddate.replace("-","/"))){
						  alert("开始时间大于结束时间，请检查!");
						  window.document.getElementById("adinfo_startdate").focus();
						   window.event.returnValue = false;
			            return;
						 }										 
						  /*if(Date.parse(adinfo_enddate.replace("-","/")) >= Date.parse(new Date())){
						  alert("结束时间大于系统时间，请检查!");
						  return false;
						 }*/
						 
			        var adinfo_starttime= window.document.getElementById("adinfo_starttime").value;
			        if(adinfo_starttime!=null &&adinfo_starttime!="")
			        {				       							     
						if(!isInt(adinfo_starttime))  
			        	{
			        		alert("开始时间点必须在0-24之间！");
			        	 	window.document.getElementById("adinfo_starttime").focus();
			           	 	window.event.returnValue = false;
			            	return;
			        	} 	
			        	if (adinfo_starttime < 0 || adinfo_starttime > 24)
							{
							    alert("开始时间点必须在0-24之间！");	
							    window.document.getElementById("adinfo_starttime").focus();
							    window.event.returnValue = false;									
								return;
							} 		
			        }
			        else
			        {	
			            alert("请输入开始时间！");
			            window.document.getElementById("adinfo_starttime").focus();
			            window.event.returnValue = false;
			            return;
			        }	
			        var adinfo_endtime= window.document.getElementById("adinfo_endtime").value;
			        if(adinfo_endtime!=null &&adinfo_endtime!="")
			        {				       							     
						if(!isInt(adinfo_endtime))  
			        	{
			        		alert("结束时间点必须在0-24之间！");
			        	 	window.document.getElementById("adinfo_endtime").focus();
			           	 	window.event.returnValue = false;
			            	return;
			        	} 	
			        	if(adinfo_endtime < 0 || adinfo_endtime > 24)
							{
							    alert("结束时间点必须在0-24之间！");	
							    window.document.getElementById("adinfo_endtime").focus();
							    window.event.returnValue = false;									
								return;
							} 		
			        }
			        else
			        {	
			            alert("请输入结束时间！");
			            window.document.getElementById("adinfo_endtime").focus();
			            window.event.returnValue = false;
			            return;
			        }	
			        	
			        var chks=document.getElementsByTagName("input");
				     var len=chks.length;		   
				     for (i=0; i<len; i++) 
				     {
				        var cur=chks[i];
				        if(cur.type=="file"&&cur.name=="resoi")
				            {  				            
				            	var fv=cur.value;				           
				            	if(fv==null||fv=='')
				            	{
				            			            	
				            	}
				            	else
				            	{
				            		var extname = fv.substring(fv.lastIndexOf(".")+1,fv.length);
									   extname = extname.toLowerCase();//处理了大小写
									    if(extname!= "bmp"&&extname!= "jpg"&&extname!= "gif"&&extname!="png")
									    {
									       alert("只能上传bmp,jpg,gif,png格式的图片！");
									       window.event.returnValue = false;
								   			 return;	
									    }			
				            		var rid=cur.id;				            		
				            		window.document.getElementById(rid.substr(4)).value=rid.substr(5);	   				
				            	}
					        }       
				    }					    
				    var chks1=document.getElementsByTagName("input");
				     var len1=chks1.length;		   
				     for (ii=0; ii<len; ii++) 
				     {
				        var cur1=chks1[ii];
				        if(cur1.type=="file"&&cur1.name=="reso")
				            {  				            
				            	var fv1=cur1.value;				           
				            	if(fv1==null||fv1=='')
				            	{
					            	alert("请选择图片上传！");	
					       			window.document.getElementById(cur1.id).focus();
								    window.event.returnValue = false;
								    return;				            	
				            	}	
				            	else
				            	{
				            			var extname = fv1.substring(fv1.lastIndexOf(".")+1,fv1.length);
									   extname = extname.toLowerCase();//处理了大小写
									    if(extname!= "bmp"&&extname!= "jpg"&&extname!= "gif"&&extname!="png")
									    {
									       alert("只能上传bmp,jpg,gif,png格式的图片！");
									       window.event.returnValue = false;
								   			 return;	
									    }	
				            		var rid=cur1.id;		
				            		//var rrid="r"+rid.substr(10);		
				            		//alert('r'+rid.substr(10)+"--"+rrid+"---"+rid+"--"+cur1.name);            		
				            		window.document.getElementById('r'+rid.substr(10)).value=rid.substr(10);		
				            		//alert(window.document.getElementById('r'+rid.substr(10)).value);	        				
				            	}			            	
					        }       
				    }					    
				    var onenumber= window.document.getElementById("adinfo_orderid").value;					     
						if(!isInt(onenumber))  
			        	{
			        		alert("显示顺序必须是大于或等于0的整数！");
			        	 	window.document.getElementById("onenumber").focus();
			           	 	window.event.returnValue = false;
			            	return;
			        	} 	
			        	
			       edform.submit();		        		      
			}	
			function isInt(str)
			{
				//var reg = /^(-|\+)?\d+$/ ;
				if(str==0)return true;
				var reg = /^[1-9]\d*$/;	
				return reg.test(str);			
			}	
						
 </script>		
</head>
<body>
<form action="EditregAd?uiid=${param.uiid}&pno=${pno}" method="post" name="edform"  enctype="multipart/form-data">
 <input type="hidden" id="adinfo_adid" name="adinfo.adid" value="${adinfo.adid}"/>
 <input type="hidden" id="adinfo_username" name="adinfo.username" value="${adinfo.username}"/>
 <div id="gonggao" class="gonggao" style="display:none">
     <img name="viewimg" id="viewimg" style="width:400;height:300"  />	
      <a href="javascript:closediv();">关闭</a>     						 
</div>
				<div>
		                <div class="l_f_top">
		                    <div class="l_f_top_left_div"><img alt="" src="../../../images/tb.gif" width="16" height="16" /></div>
		                    <div class="l_f_top_right_div">修改广告       </div>
		                </div>
		                <div class="l_f_body"> 
		                 <div class="l_f_body_row">
		                        <div class="l_f_body_div1">                            名称:</div>
		                        <div class="l_f_body_div5">
				                       <input type="text"  name ="adinfo.title" id="adinfo_title" value="${adinfo.title}" style="width:150px"/>  
					           </div>                      
		                    </div>	  			                    
		      			  <div class="l_f_body_row">
		                        <div class="l_f_body_div1">                            URL:</div>
		                        <div class="l_f_body_div5">
				                       <input type="text"  name ="adinfo.url" id="adinfo_url" value="${adinfo.url}" style="width:150px"/>  
					           </div>                      
		                    </div>	 
		                    <div class="l_f_body_row">
								<div class="l_f_body_div1">
									开始日期:
								</div>
								<div class="l_f_body_div5">
									<input type="text" onclick="show_calendar(this)" name="adinfo.startdate" value="${adinfo.startdate}" id="adinfo_startdate" style="width:150px"/>									
								</div>
							</div>							
							<div class="l_f_body_row">
								<div class="l_f_body_div1">
									结束日期:
								</div>
								<div class="l_f_body_div5">
									<input type="text" onclick="show_calendar(this)" name="adinfo.enddate" value="${adinfo.enddate}" id="adinfo_enddate" style="width:150px"/>									
								</div>
							</div>  
		                    <div class="l_f_body_row">
								<div class="l_f_body_div1">
									开始时间:
								</div>
								<div class="l_f_body_div5">
									<input type="text" name="adinfo.starttime" id="adinfo_starttime" value="${adinfo.starttime}" style="width:120px" maxlength="2"/>
									点
								</div>
							</div>							
							<div class="l_f_body_row">
								<div class="l_f_body_div1">
									结束时间:
								</div>
								<div class="l_f_body_div5">
									<input type="text" name="adinfo.endtime" id="adinfo_endtime" value="${adinfo.endtime}"  style="width:120px" maxlength="2"/>
									点
								</div>
							</div>
							<div class="l_f_body_row">
					<div class="l_f_body_div1">
					&nbsp;省&nbsp;&nbsp;份：
					</div>
					<div class="l_f_body_div5">
					<input type="checkbox" name="checkall" id="checkall" onclick="test(this)" />全选<br/>					
					<c:forEach items="${prolist}" var="pro" varStatus="status">
					        <c:if test="${status.count%8==0}" >
					        <c:set var="isDoing" value="0"/>
					        <c:forEach items="${plist}" var="p" >
					       <c:if test="${pro.PId==p}"><input type="checkbox" name="province" id="province" checked="checked" value="${pro.PId}"/>${pro.provincename}<br/>
                                 <c:set var="isDoing" value="1"/>
					       </c:if>
					       </c:forEach>
					       <c:if test="${isDoing!='1'}">
					           <input type="checkbox" name="province" id="province"  value="${pro.PId}"/>${pro.provincename}<br/>
					       </c:if>
					      </c:if> 
					       
					        <c:if test="${status.count%8!=0}" >
					        <c:set var="isDoing" value="0"/>
					        <c:forEach items="${plist}" var="p" >
					       <c:if test="${pro.PId==p}"><input type="checkbox" name="province" id="province" checked="checked" value="${pro.PId}"/>${pro.provincename}
                                 <c:set var="isDoing" value="1"/>
					       </c:if>
					       </c:forEach>
					       <c:if test="${isDoing!='1'}">
					           <input type="checkbox" name="province" id="province"  value="${pro.PId}"/>${pro.provincename}
					       </c:if>
					      </c:if> 
					       
					</c:forEach>
					</div>					
				</div>
		                    ${ResolutionList}
		                      <div class="l_f_body_row" style="display:none">
							<div class="l_f_body_div1">
								显示顺序:
							</div>
							<div class="l_f_body_div5">
								<input type="text" name="adinfo.orderid" id="adinfo_orderid"  value="${adinfo.orderid}"  style="width:120px" maxlength="2"/>
							</div>
						</div>
		                     <div class="l_f_body_row">
		                        <div class="l_f_body_div1">                             状态:</div>
		                        <div class="l_f_body_div5" >
		               		     <select name="adinfo.isshow" id="adinfo_isshow" style="width: 120px">									
									<option value="-1">等待审核</option>		          						
		          				</select>
							   </div>
		                    </div>		  
		                     <div class="center l_f_body_foot">			                     
		                       <input type="button" id="button" name="button" class="button2_60" onclick="checkData();"  value="提交"/>			                     
		                     <input type="button" class="button2_60"  onclick="javascript:history.go(-1);" value=" 返回"/> 
		                   </div>
		                </div>
			    	</div> 	
</form>
</body>
</html>